export const LoginType = {
	MiniApp: "miniapp", //小程序
	WeChat: "wechat", //公众号
}

export const Toast = {
	success(title) {
		let _ = this;
		_.hideLoading();
		uni.showToast({
			title: title,
			icon: "success"
		})
	},
	error(title) {
		let _ = this;
		_.hideLoading();
		uni.showToast({
			title: title,
			icon: "none",
		})
	},
	//使用默认标题
	loading() {
		uni.showLoading({
			title: "加载中",
			mask: true,
		});
	},
	//带标题
	loadingT(title) {
		uni.showLoading({
			title: title,
			mask: true,
		});
	},
	hideLoading() {
		uni.hideLoading();
	},
}

/**
 * 克隆
 * @param {*} object 
 * @param {*} deep  是否深度克隆
 */
export const clone = (object, deep) => {
	if (object == null || typeof object == "object") {
		return object;
	}
	var result = new object.constructor();
	for (var propertyName in object) {
		if (object.hasOwnProperty(propertyName)) {
			var value = object[propertyName];
			if (deep) {
				value = clone(value, deep);
			}
			result[propertyName] = value;
		}
	}
	return result;
}

export const DefaultHead = "/images/default_head.png";

export const SexOpts = [{
		label: "男",
		value: "Man",
		id: "Man"
	},
	{
		label: "女",
		value: "Woman",
		id: "Woman"
	},
	{
		label: "未设置",
		value: "Unknow",
		id: "Unknow"
	},
];
